package d0326;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;

public class Test {
    public static void main(String[] args) {
        //关键字数组
        String[] keywords = {"abstract", "default", "goto", "null", "switch", "boolean", "do", "if", "package",
                "synchronized", "break", "double", "implements", "private", "this", "byte", "else",
                "import", "protected", "throw", "throws", "case", "extends", "instanceof", "public",
                "transient", "catch", "false", "int", "return", "true", "char", "final", "interface",
                "short", "try", "class", "finally", "long", "static", "void", "const", "float", "native",
                "strictfp", "volatile", "continue", "for", "new", "super", "while", "assert", "enum"};
        int[] keywordsnum = new int[keywords.length];
        try {
            File file = new File("d://a.txt");
            FileReader fr = new FileReader(file);
            BufferedReader br = new BufferedReader(fr);
            String[] values = br.readLine().split(" ");
            for (String str : values) {
                for (int i = 0;i < keywords.length;i++) {
                    if(str.equals(keywords[i])) {
                        keywordsnum[i]++;
                    }
                }
            }
            for(int i = 0; i < keywordsnum.length;i++) {
                if(keywordsnum[i] != 0) {
                    System.out.println(keywords[i]+" "+keywordsnum[i]);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
